<template>
  <div>
    <el-card class="box-card" shadow="false">
      <div slot="header" class="clearfix">
        <span>基本信息</span>
      </div>
      <el-row :gutter="20" style="margin-bottom: 20px">
        <el-col :span="6">
          <div class="title">运输任务编号：<span class="item">{{ carData.transportTaskId }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">车牌号码：<span class="item">{{ carData.licensePlate }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">起始地机构：<span class="item">{{ carData.startAgencyName }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">目的地机构：<span class="item">{{ carData.endAgencyName }}</span></div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="title">出车时间：<span class="item">{{ carData.outStorageTime }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">回车时间：<span class="item">{{ carData.intoStorageTime }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">司机：<span class="item">{{ carData.driverName }}</span></div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="box-card" shadow="false">
      <div slot="header" class="clearfix">
        <span>故障信息</span>
      </div>
      <el-row :gutter="24" style="margin-bottom: 20px">
        <el-col :span="8">
          <div class="title">车辆故障：<span class="item">{{ carData.isFault ? '是' : '否' }}</span></div>
        </el-col>
        <el-col :span="8">
          <div class="title">是否可用：<span class="item">{{ carData.isAvailable? '是' : '否' }}</span></div>
        </el-col>
        <el-col :span="8">
          <div class="title">故障类型：
            <span v-if="carData.faultType === 1" class="item">发动机启动困难</span>
            <span v-else-if="carData.faultType === 2" class="item">不着车</span>
            <span v-else-if="carData.faultType === 3" class="item">漏油</span>
            <span v-else-if="carData.faultType === 4" class="item">漏水</span>
            <span v-else-if="carData.faultType === 5" class="item">照明失灵</span>
            <span v-else-if="carData.faultType === 6" class="item">有异响</span>
            <span v-else-if="carData.faultType === 7" class="item">排烟异常</span>
            <span v-else-if="carData.faultType === 8" class="item">温度异常</span>
            <span v-else-if="carData.faultType === 9" class="item">其他</span>
            <span v-else class="item">无</span>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <div style="display:flex" class="title">故障图片：
            <span @click="isShow = true">
              <img class="img" :src="carData.faultImages" alt="">
            </span>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="box-card" shadow="false">
      <div slot="header" class="clearfix">
        <span>违章信息</span>
      </div>
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="title">车辆违章：<span class="item">{{ carData.isBreakRules ? '是' : '否' }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">违章类型：
            <span v-if="carData.faultDescription === 1" class="item">闯红灯</span>
            <span v-else-if="carData.faultDescription === 2" class="item">无证驾驶</span>
            <span v-else-if="carData.faultDescription === 3" class="item">超载</span>
            <span v-else-if="carData.faultDescription === 4" class="item">酒后驾驶</span>
            <span v-else-if="carData.faultDescription === 5" class="item">超速行驶</span>
            <span v-else class="item">无</span>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="title">罚款金额：
            <span v-if="carData.penaltyAmount" class="item">{{ carData.penaltyAmount }}元</span>
            <span v-else class="item">0元</span>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="title">扣分：
            <span v-if="carData.deductPoints" class="item">{{ carData.deductPoints }}元</span>
            <span v-else class="item">0元</span>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="box-card" shadow="false">
      <div slot="header" class="clearfix">
        <span>事故信息</span>
      </div>
      <el-row :gutter="20" style="margin-bottom: 20px">
        <el-col :span="6">
          <div class="title">车辆事故：<span class="item">{{ carData.accidentDescription ? '是' : '否' }}</span></div>
        </el-col>
        <el-col :span="6">
          <div class="title">事故类型：
            <span v-if="carData.accidentType === 1" class="item">直行事故</span>
            <span v-else-if="carData.accidentType === 2" class="item">追尾事故</span>
            <span v-else-if="carData.accidentType === 3" class="item">超车事故</span>
            <span v-else-if="carData.accidentType === 4" class="item">左转弯事故</span>
            <span v-else-if="carData.accidentType === 5" class="item">右转弯事故</span>
            <span v-else-if="carData.accidentType === 6" class="item">弯道事故</span>
            <span v-else-if="carData.accidentType === 7" class="item">坡道事故</span>
            <span v-else-if="carData.accidentType === 8" class="item">会车事故</span>
            <span v-else-if="carData.accidentType === 9" class="item">其他</span>
            <span v-else class="item">无</span>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <div style="display:flex" class="title">事故图片：
            <span @click="isShow = true">
              <img class="img" :src="carData.accidentImages" alt="">
            </span>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-dialog
      :visible.sync="isShow"
      width="600px"
    >
      <img style="width:600px;height:600px;" :src="carData.faultImages" alt="">
    </el-dialog>
  </div>
</template>

<script>
import { getCarReceiptApi } from '@/api/carRegister'
export default {
  data() {
    return {
      carData: {},
      isShow: false
    }
  },
  async created() {
    const res = await getCarReceiptApi(this.$route.params.id)
    console.log(res)
    this.carData = res
  }
}
</script>

<style scoped lang="scss">
.box-card{
  margin: 20px;
  border:none;
  ::v-deep .el-card__header{
  background-color: #f8faff;
  border:none;
  padding: 0;
  }
  ::v-deep .el-card__body{
    padding-left: 45px!important;
    padding-right: 0!important;
  }
  .clearfix{
    margin-top: 0;
    height: 60px;
    background-color: #f8faff;
    padding: 20px 20px 20px 44px;
    margin-bottom: 8px;
    color: #2a2929;
    font-size: 16px;
    font-weight: 700;
  }
  .title{
    min-width: 100px;
    font-weight: 400;
    color: #20232a;
    font-size: 14px;
    .item{
    background-color: #fff;
    border: none;
    height: 20px;
    color: #818693;
    }
  }
  .img{
    width: 212px;
    height: 159px;
    border-radius: 4px;
  }
}
  ::v-deep .el-dialog__header{
  padding: 0;
}
  ::v-deep .el-dialog__body{
  padding: 0;
}
</style>
